<%@page import="com.jfinal.kit.PropKit" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="cn.com.dashihui.web.common.OrderCode" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>兑换验证</title>
    <jsp:include page="../../include/header.jsp"></jsp:include>
     <style type="text/css">
      input{outline:none;}
		.aaa{
			margin-left: 200px;
			font-size: 16px;
			margin-top: 5px;
		}
	</style>
</head>
<body>
<div id="wrapper">

		<div class="row">
			<div style="width: 100%;height: 10%;text-align: center;">			
				<h1 class="page-header">产品兑换信息验证</h1>		
		</div>
		</div>
		<!-- 搜索框 -->
		<div class="row">
			 <h4 style="margin-left:200px;;float:left">请输入产品验证码</h4>
		    <div style="width:20%;margin-left:2%;float:left;" >
	        	<input type="text" name="duihuanma"  id="sOrderNum" class="form-control" placeholder="" maxlength="20" />
		   </div>
			<div style="margin-right:15%;">
				<button  class="btn btn-success search-btn" onclick="doduihuan();">确定</button>
			</div>
				<div class="clearfix"></div>
		</div>
		
		<div class="bbb">
		  <div class="row" style="margin-top:20px;">
		        <div class="aaa">
					<label>订单编号：</label><span >${item.orderNum }</span>
				</div>
				<div class="aaa">
					 <label>状态：</label>
					
					 <c:if test="${item.payState==1 }">
						<span style="color: red">待支付</span>
					 </c:if>
					 <c:if test="${item.payState==2 and item.tuistate==0}">
						 <c:if test="${item.orderState==1 }">
						    <span style="color: red">未兑换</span>
						 	<button  class="btn btn-success" onclick="doEatr('${item.orderNum}');">兑换</button>
						 </c:if>
						 <c:if test="${item.orderState==2 }">
							<span style="color: red">已付款</span>
						 </c:if>
						 <c:if test="${item.orderState==3 }">
							<span style="color: red">过期</span>
						</c:if>
					 </c:if>
					 <c:if test="${item.tuistate==1 }">
						<span style="color: red">退款中</span>
					 </c:if>
					 <c:if test="${item.tuistate==2}">
						<span style="color: red">已退款</span>
					 </c:if>
				</div>
		  </div>
		  <div class="row">
		       <div class="aaa">
					<label>联系方式：</label><span>${item.tel }</span>
				</div>
				<div class="aaa">
					<label>下单分公司：</label><span>${item.xdtitel }</span>
				</div>
		  </div>
		  <div class="row">
		        <div class="aaa">
					<label>兑换物品名称：</label><span>${item.goodsName}</span>
				</div>
				<div class="aaa">
					<label>下单时间：</label><span>${item.startDate }</span>
				</div>
		  </div>
		   <div class="row">
		       <div class="aaa">
					<label >兑换数量：</label><span>${item.countnum }</span>
				</div>
				<div class="aaa">
					<label >兑换有效期：</label><span>${item.guoDate }</span>
				</div>
		  </div>
		   <div class="row">
		        <div class="aaa">
					<label>兑换时间：</label><span>${item.deliverDate}</span>
				</div>


				<div class="aaa">
					<label>兑换分公司：</label><span>${item.dhtitel }</span>

				</div>
		  </div>
       </div>
      </div>


<jsp:include page="../../include/javascripts.jsp"></jsp:include>
<script type="text/javascript">
var detailDialog;
function doduihuan(){
	var duihuanma = $("#sOrderNum").val();
	if(duihuanma==null ||duihuanma==""||duihuanma==undefined){
		Kit.alert("请输入兑换码");return;
	}else{
		
		//window.location.href="${BASE_PATH}/bus/order/doduihuan?duihuanma="+duihuanma;
	 	$.post("${BASE_PATH}/bus/order/doduihuan",{'duihuanma':duihuanma},function(result){
			 if(result.flag==0){
				 Kit.alert("兑换成功！");
				 window.location.href="${BASE_PATH}/bus/order/dodui?duihuanma="+duihuanma;
				}
			else if(result.flag==1){
				Kit.alert("无法在该分公司进行兑换！");return;
			
			}else{
				window.location.reload(true);
			}
			
		}); 
	}
	
}

function doEatr(orderNum){
	Kit.confirm("提示","确定要兑换商品吗？",function(ref){
		$.post("${BASE_PATH}/bus/order/doEatr",{'orderNum':orderNum},function(result){
			if(result.flag==0){
				
				window.location.reload(true);
			     alert("兑换成功！");
			}else{
				Kit.alert("兑换失败！");return;
			}
			
		});
	});
}

</script>
</body>
</html>